const webpack = require('webpack')
const path = require('path')
const FileManagerPlugin = require('filemanager-webpack-plugin')

module.exports = {
    mode: 'production',
    entry: {
        vendor: [
            'babel-polyfill',
            'lodash',
            'antd',
            'react-router-dom'
        ],
    },

    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: 'js/vendor.js',
        library: 'global_vendor',
    },

    externals: {
        //"react": "React",
        "jquery": "jQuery"
    },

    plugins: [
        new webpack.DllPlugin({
            path: path.join(__dirname, 'vendor-manifest.json'),
            name: 'global_vendor',
            context: __dirname,
        }),
        new FileManagerPlugin({
            onEnd: {
                copy: [{
                    source: path.resolve(__dirname, 'dist/**/*'),
                    destination: path.resolve(__dirname, '../src/main/resources/static/dist/')
                },{
                    source: path.resolve(__dirname, 'dist/**/*'),
                    destination: path.resolve(__dirname, '../out/production/classes/static/dist/')
                }]
            }
        }),
    ]
}
